<?php
//tags
$tags_html = '';
$keys = BUtils::DetailFeaturesKeys();
foreach ($keys as $key) {
	if (!empty($model[$key])) {
		$string = '';
		$array = explode(',', $model[$key]);
		foreach ($array as $item) {
			$string .= '<span class="label tags">' . BUtils::T($item) . '</span> ';
		}
		$tags_html .= '<div class="tags-title">' . BUtils::T($key . '_lbl') . ':</div><div class="tags-body">'.$string.'</div>';
	}
}

//hours
$hours_list = '';
if (!empty($model['hours'])) {
	//define array
	$aWeekDaysShort = BUtils::WeekDayKeys(7, true);
	$aOpenningHours = BUtils::AllHour24();
	
	//set open hours display style
	$sWeekBuffer = array();
	foreach ($model['hours'] as $v) {
		$sWeekday = $aWeekDaysShort[$v['week_no']];
		$sHours = $aOpenningHours[$v['open_hour']] . ' - ' . $aOpenningHours[$v['close_hour']];
		$sWeekBuffer[$sHours][] = $v['week_no'];//add the current week day
	}
	$i = 0;
	foreach ($sWeekBuffer as $key => $v) {
		$size = count($v);
		if ($size > 1) $sWeekday = $aWeekDaysShort[$v[0]] . '-' . $aWeekDaysShort[$v[$size-1]];
		else $sWeekday = $aWeekDaysShort[$v[0]];
		$hours_list .= '<span class="weekday">'.$sWeekday.'</span> <span class="hours">'.$key.'</span><br />';
	}
}
?>
<style>
.box_white .panel{margin-top:0;}
.label.tags {background:#0be;}
.tags-title {font-weight:bold;}
.tags-body {margin-left:24px; margin-bottom:6px;}
</style>
<div class="row-fluid">
	<div class="span12" style="margin-top:15px;">
<?php if (!empty($model['hours'])) { ?>
		<div class="box_white relative">
			<div class="title-bar">
				<h4 class="blue"><?php echo BUtils::T('opening_hours_lbl'); ?></h4>
			</div>
			<div class="panel clearfix">
				<?php echo $hours_list; ?>
			</div>
		</div>
<?php } ?>
<?php if (!empty($tags_html)) { ?>
		<div class="box_white relative">
			<div class="title-bar">
				<h4 class="blue"><?php echo BUtils::T('detail_features_lbl'); ?></h4>
			</div>
			<div class="panel clearfix">
				<?php echo $tags_html; ?>
			</div>
		</div>
<?php } ?>
	</div>
</div>
